//package com.sskj.kafka;
//
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.web.bind.annotation.PostMapping;
//import org.springframework.web.bind.annotation.RequestBody;
//import org.springframework.web.bind.annotation.RequestMapping;
//import org.springframework.web.bind.annotation.RestController;
//
//@RestController
//@RequestMapping("/kafka")
//public class KafkaController {
//
//    @Autowired
//    private KafkaProducer  kafkaProducerService;
//
//    @PostMapping("/send")
//    public String sendMessage(@RequestBody String message) {
//        kafkaProducerService.sendMessage("my-topic", message);
//        return "Message sent: " + message;
//    }
//
//    @PostMapping("/send-with-key")
//    public String sendMessageWithKey(@RequestBody String message) {
//        kafkaProducerService.sendMessageWithKey("my-topic", "key1", message);
//        return "Message with key sent: " + message;
//    }
//
//    @PostMapping("/send-async")
//    public String sendAsyncMessage(@RequestBody String message) {
//        kafkaProducerService.sendAsyncMessage("my-topic", message, new KafkaCallback<String, String>(){});
//        return "Async message sent: " + message;
//    }
//
//    @PostMapping("/send-async-with-key")
//    public String sendAsyncMessageWithKey(@RequestBody String message) {
//        kafkaProducerService.sendAsyncMessageWithKey("my-topic", "key1", message, new KafkaCallback<String, String>(){});
//        return "Async message with key sent: " + message;
//    }
//}
